home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / Softshoe / Lisa's Mac Parts / Activation / SubWindowFocus.cp < prev    next >
Text File  |  2000-06-23  |  4KB  |  168 lines

  1. // SubWindowFocus.cp
  2.  
  3. #ifndef SubWindowFocus_h
  4. #include "SubWindowFocus.h"
  5. #endif
  6.  
  7. SubWindowFocus::SubWindowFocus( WindowFocus& window, AtStart )
  8.   : Focus( below, window ),
  9.      Enableable( true ),
  10.      link( this ),
  11.      siblings( window.subFoci ),
  12.      tabber( window, *this )
  13.   {
  14.     window.subFoci.Add( link, beforeStart );
  15.   }
  16.  
  17. SubWindowFocus::SubWindowFocus( WindowFocus& window, AtEnd )
  18.   : Focus( below, window ),
  19.      Enableable( true ),
  20.      link( this ),
  21.      siblings( window.subFoci ),
  22.      tabber( window, *this )
  23.   {
  24.     window.subFoci.Add( link, afterEnd );
  25.   }
  26.  
  27. SubWindowFocus::SubWindowFocus( WindowFocus& window,
  28.                                           Before,
  29.                                           SubWindowFocus& sibling )
  30.   : Focus( below, window ),
  31.      Enableable( true ),
  32.      link( this ),
  33.      siblings( window.subFoci ),
  34.      tabber( window, *this )
  35.   {
  36.     window.subFoci.Add( link, before, sibling.link );
  37.   }
  38.  
  39. SubWindowFocus::SubWindowFocus( WindowFocus& window,
  40.                                           After,
  41.                                           SubWindowFocus& sibling )
  42.   : Focus( below, window ),
  43.      Enableable( true ),
  44.      link( this ),
  45.      siblings( window.subFoci ),
  46.      tabber( window, *this )
  47.   {
  48.     window.subFoci.Add( link, after, sibling.link );
  49.   }
  50.  
  51. SubWindowFocus::SubWindowFocus( WindowFocus& window,
  52.                                           TabKeys& tabHandler,
  53.                                           AtStart )
  54.   : Focus( below, window ),
  55.      Enableable( true ),
  56.      link( this ),
  57.      siblings( window.subFoci ),
  58.      tabber( window, tabHandler )
  59.   {
  60.     window.subFoci.Add( link, beforeStart );
  61.   }
  62.  
  63. SubWindowFocus::SubWindowFocus( WindowFocus& window,
  64.                                           TabKeys& tabHandler,
  65.                                           AtEnd )
  66.   : Focus( below, window ),
  67.      Enableable( true ),
  68.      link( this ),
  69.      siblings( window.subFoci ),
  70.      tabber( window, tabHandler )
  71.   {
  72.     window.subFoci.Add( link, afterEnd );
  73.   }
  74.  
  75. SubWindowFocus::SubWindowFocus( WindowFocus& window,
  76.                                           TabKeys& tabHandler,
  77.                                           Before,
  78.                                           SubWindowFocus& sibling )
  79.   : Focus( below, window ),
  80.      Enableable( true ),
  81.      link( this ),
  82.      siblings( window.subFoci ),
  83.      tabber( window, tabHandler )
  84.   {
  85.     window.subFoci.Add( link, before, sibling.link );
  86.   }
  87.  
  88. SubWindowFocus::SubWindowFocus( WindowFocus& window,
  89.                                           TabKeys& tabHandler,
  90.                                           After,
  91.                                           SubWindowFocus& sibling )
  92.   : Focus( below, window ),
  93.      Enableable( true ),
  94.      link( this ),
  95.      siblings( window.subFoci ),
  96.      tabber( window, tabHandler )
  97.   {
  98.     window.subFoci.Add( link, after, sibling.link );
  99.   }
  100.  
  101. void SubWindowFocus::PassFocusForward()
  102.   {
  103.     for ( const ListLink<SubWindowFocus> *p = link.Next();
  104.             p != 0;
  105.             p = p->Next() )
  106.         if ( (*p)->Enabled() )
  107.           {
  108.             Parent()->FavorChild( **p );
  109.             return;
  110.           }
  111.     
  112.     for ( const ListLink<SubWindowFocus> *p = siblings.First();
  113.             p != &link;
  114.             p = p->Next() )
  115.         if ( (*p)->Enabled() )
  116.           {
  117.             Parent()->FavorChild( **p );
  118.             return;
  119.           }
  120.   }
  121.  
  122. void SubWindowFocus::PassFocusBackward()
  123.   {
  124.     for ( const ListLink<SubWindowFocus> *p = link.Previous();
  125.             p != 0;
  126.             p = p->Previous() )
  127.         if ( (*p)->Enabled() )
  128.           {
  129.             Parent()->FavorChild( **p );
  130.             return;
  131.           }
  132.     
  133.     for ( const ListLink<SubWindowFocus> *p = siblings.Last();
  134.             p != &link;
  135.             p = p->Previous() )
  136.         if ( (*p)->Enabled() )
  137.           {
  138.             Parent()->FavorChild( **p );
  139.             return;
  140.           }
  141.   }
  142.  
  143. void SubWindowFocus::TabForward( const KeystrokeEvent& )
  144.   {
  145.     PassFocusForward();
  146.   }
  147.  
  148. void SubWindowFocus::TabBackward( const KeystrokeEvent& )
  149.   {
  150.     PassFocusBackward();
  151.   }
  152.  
  153. void SubWindowFocus::BeEnabled()
  154.   {
  155.     if ( Parent()->FavoredChild() == 0 )
  156.         Parent()->FavorChild( *this );
  157.   }
  158.  
  159. void SubWindowFocus::BeDisabled()
  160.   {
  161.     if ( Parent()->FavoredChild() == this )
  162.       {
  163.         PassFocusForward();
  164.         if ( Parent()->FavoredChild() == this )
  165.             Parent()->FavorNoChild();
  166.       }
  167.   }
  168.